"""bzShop URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from django.urls import path
import xadmin
from bzShop.settings import MEDIA_ROOT
from django.views.static import serve


from django.contrib.auth.views import LoginView,LogoutView

from rest_framework.authtoken import views

# from  good.views import GoodsListView

from rest_framework.documentation import include_docs_urls

from good.views import GoodsListViewSet,GoodsCategoryViewSet

from user.views import UserRegViewSet

from user_operation.views import UserFavViewSet

from rest_framework_jwt.views import obtain_jwt_token

# good_list = GoodsListViewSet.as_view({
#     'get':'list',
# })

# from good import views

from rest_framework.routers import DefaultRouter



router = DefaultRouter()

router.register(r'goods', GoodsListViewSet,base_name="goods")

#配置category的url
router.register(r'categorys', GoodsCategoryViewSet, base_name="categorys")


#配置用户注册的url
router.register(r'userReg', UserRegViewSet, base_name="userReg")

#用户收藏
router.register(r'userfavs', UserFavViewSet, base_name='userfavs')

urlpatterns = [
    # path('login/', LoginView.as_view(template_name='xadmin/views/login.html'), name="login"),
    path('admin/', admin.site.urls),
    # url(r'^login/$', LoginView.as_view(), name="login"),
    # url(r'^logout/$', LogoutView.as_view(), name="logout"),

    url(r'^xadmin/', xadmin.site.urls),

    url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}),

    # url(r'^api-auth/', include('rest_framework.urls')),

    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),

    url(r'docs/', include_docs_urls(title="bzShop")),

    url(r'^', include(router.urls)),

    #drf自带的token认证模式
    url(r'^api-token-auth/', views.obtain_auth_token),


     # url(r'docs/',include_docs_urls(title='bzShop',authentication_classes=[],
     #                                permission_classes=[])),

     #商品列表页
     # url(r'goods/$', good_list, name='goods_list'),

    # jwt的认证接口
    url(r'^login/', obtain_jwt_token),


]
